
<?php
session_start();
require_once '../models/Users.php';require_once '../models/Product.php';
$mgs="";
$modelID= $_REQUEST['modelID'];
$rows	= Product::getModelInfo($modelID);

if(isset($_POST['btn_submit'])){
	$modelName=$_POST["modelName"];
	$re=Product::updateModel($modelID,$modelName);
	if($re){
		$mgs="Cập nhật thành công!";
		$page="update_model.php?modelID=".$modelID;
		//$page="ql_model.php";
		Product::redirectTo($page);
	}else $mgs="Cập nhật thất bại !!!";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Update Model</title>
<?php include '../admin/_meta.php';?>
</head>
<body>
<form method="post" action="update_model.php?modelID=<?php echo $modelID;?>">
	<div id="firstLine">
		<div id="top-bar">
		<?php include '_top_bar_admin.php';?>
		</div>
	</div>
	<div id="container">
		<div id="header">
			<?php include '_menu_admin.php';?>
		</div>
		<div id="center">
			<div id="table-user">
				<table id="table-admin">
					<tr>
						<td colspan="2"><b>Update Model</b></td>
					</tr>
					<tr>
						<td>Model ID</td>
						<td><input type="text" name="modelID" value="<?php echo $rows["modelID"];?>" disabled="disabled"></td>
					</tr>
					<tr>
						<td>Brand Name</td>
						<td><input type="text" name="modelName" value="<?php echo $rows["brandName"];?>"  disabled/></td>
					</tr>
					<tr>
						<td>Name</td>
						<td><input type="text" name="modelName" value="<?php echo $rows["modelName"];?>" /></td>
					</tr>
					<tr>
						<td><input type="submit" name="btn_submit" value="Cập nhật" class="btn_submit"></td>
						<td><a href="ql_model.php"><input type="button" name="button" value="Quay lại" class="btn_submit"></a></td>
					</tr>
					<tr>
						<td colspan="2"><?php echo $mgs; ?></td>
					</tr>
					</table>
					<?php //Users::listModel();?>
			</div>
			</div>
		</div>
	</div>
	</div>
	<div>
		<?php include '_footer_admin.php';?>
	</div>
</form>
</body>
</html>
				
				
